<template>
	<div class="uiue-card">
		<div class="tit">基本信息</div>
		<a-form ref="formRef" :model="formData" :rules="formRules" layout="vertical" class="form-box">
			<a-row v-for="(item, index) in formOption" :key="index" :gutter="75">
				<a-col :span="8" v-for="v in item" :key="v.prop">
					<a-form-item :name="v.prop">
						<LabelDes :label="v.label" :prop="v.prop" />
						<a-input v-if="v.type === 'text'" v-model:value="formData[v.prop]" :placeholder="v.placeholder"
							:maxlength="v.maxlength" allow-clear />
						<a-select v-if="v.type === 'select'" v-model:value="formData[v.prop]"
							:placeholder="v.placeholder" :options="v.option" allow-clear />
						<a-select v-if="v.type === 'select1'" v-model:value="formData[v.prop]"
							:placeholder="v.placeholder" :options="v.option" :disabled="isEdit" @change="handleRnChange"
							allow-clear />
						<a-select v-if="v.type === 'appRange'" v-model:value="formData[v.prop]"
							:placeholder="v.placeholder" :options="appRangeLists" :disabled="isEdit" allow-clear
							show-search :filter-option="filterOption"
							:field-names="{ label: 'orgName', value: 'deptId' }" @change="handleChange" />
						<a-select v-if="v.type === 'appContact'" v-model:value="formData[v.prop]"
							:placeholder="v.placeholder" :options="personList" @change="appContactChange" allow-clear
							:field-names="{ label: 'name', value: 'id' }" />

						<a-radio-group v-if="v.type === 'radio'" v-model:value="formData[v.prop]">
							<a-radio value="1">有效</a-radio>
							<a-radio value="0">无效</a-radio>
						</a-radio-group>
						<a-date-picker ref="pick" style="width: 100%" valueFormat="YYYY-MM-DD" v-if="v.type === 'date'"
							:showToday="false" v-model:value="formData[v.prop]">
							<template #renderExtraFooter>
								<!-- <a-button type="primary" @click="submit" size="mini">永久</a-button> -->
								<a-button type="link" block @click="lasting">永久</a-button>
							</template>
						</a-date-picker>
					</a-form-item>
				</a-col>
			</a-row>
			<a-row :gutter="75">
				<a-col :span="8">
					<a-form-item name="appAccess">
						<LabelDes label="双端接入" prop="appAccess" />
						<a-checkbox-group v-model:value="formData.appAccess" :disabled="isDisabled()"
							@change="handleAccessChange">
							<a-checkbox value="1" name="mh" disabled>门户端</a-checkbox>
							<a-checkbox value="2" name="yd">移动端Html</a-checkbox>
						</a-checkbox-group>
					</a-form-item>
				</a-col>

				<a-col :span="8" v-if="isShowTime">
					<a-form-item name="appOnlineTime">
						<LabelDes label="移动端预计上线时间" prop="appOnlineTime" />
						<a-date-picker style="width: 100%" v-model:value="formData.appOnlineTime"
							valueFormat="YYYY-MM-DD" :showToday="false" :disabled-date="disabledDate" />
					</a-form-item>
				</a-col>
			</a-row>
			<a-row :gutter="75">
				<a-col :span="8" v-if="pcTodoShow">
					<a-form-item name="isPcTodo" required>
						<LabelDes label="是否接门户端待办" prop="isPcTodo" />
						<a-radio-group v-model:value="formData.isPcTodo" :options="radioOption"
							@change="handleTodoChange" />
					</a-form-item>
				</a-col>
				<a-col :span="8" v-if="pcTodoShow">
					<a-form-item name="isPcReadtodo" required>
						<LabelDes label="是否接门户端待阅" prop="isPcReadtodo" />
						<a-radio-group v-model:value="formData.isPcReadtodo" :options="radioOption"
							@change="handleToReadChange" />
						<!-- <a-radio-group v-model:value="formData.isPcReadtodo" :options="radioOption"
							:disabled="formData.isPcTodo === '0' || tableName === 'MOBILE'"
							@change="handleToReadChange" /> -->
					</a-form-item>
				</a-col>
				<a-col :span="8" v-if="showPhoneRemark">
					<a-form-item name="noAccessTypeRemark">
						<LabelDes label="无法双端同步接入待办待阅原因" prop="noAccessTypeRemark" />
						<a-select v-model:value="formData.noAccessTypeRemark" placeholder="请选择原因"
							:options="tool.dictList('REASON_ACCESS')" allow-clear />
					</a-form-item>
				</a-col>

			</a-row>
			<a-row :gutter="75">
				<a-col :span="8" v-if="appTodoShow">
					<a-form-item name="isAppTodo" required>
						<LabelDes label="是否接移动端待办" prop="isAppTodo" />
						<a-radio-group v-model:value="formData.isAppTodo" :options="radioOption"
							@change="handleTodoChangePhone" />
						<!-- :disabled="formData.isPcTodo === '0' && formData.appAccess?.length > 1" /> -->
					</a-form-item>
				</a-col>
				<a-col :span="8" v-if="appTodoShow">
					<a-form-item name="isAppReadtodo" required>
						<!-- :disabled="formData.isAppTodo === '0' || (formData.isPcTodo === '0' && formData.appAccess?.length > 1)" -->
						<LabelDes label="是否接移动端待阅" prop="isAppReadtodo" />
						<a-radio-group v-model:value="formData.isAppReadtodo" :options="radioOption"
							@change="handleToReadChangePhone" />
					</a-form-item>
				</a-col>
				<a-col :span="8" v-if="formData.noAccessTypeRemark == 5">
					<a-form-item name="appRemark">
						<LabelDes label="无法双端同步接入待办待阅其他原因" prop="noAccessTypeRemark" />
						<a-textarea type="textarea" v-model:value="formData.appRemark" placeholder="请输入原因"
							allow-clear />
					</a-form-item>
				</a-col>
			</a-row>
			<a-row>
				<a-col :span="24">
					<a-form-item name="appDescription">
						<LabelDes label="应用介绍" prop="appDescription" />
						<a-textarea :maxlength="200" type="textarea" v-model:value="formData.appDescription"
							:auto-size="{ minRows: 3, maxRows: 5 }" placeholder="请输入不超过200字的应用介绍" allow-clear />
					</a-form-item>
				</a-col>
			</a-row>
			<a-row>
				<a-col :span="24">
					<a-form-item name="otherInfo">
						<LabelDes label="其他说明" prop="" :isShow="false" :isRequ="false" />
						<a-textarea :maxlength="200" type="textarea" v-model:value="formData.otherInfo"
							:auto-size="{ minRows: 3, maxRows: 5 }" placeholder="请输入不超过200字" allow-clear />
					</a-form-item>
				</a-col>
			</a-row>
		</a-form>
	</div>
	<!-- <PickPeople ref="pick" @succses="setUser" :setPersions="true" v-if="roleList.length > 0" :roleList="roleList" /> -->
</template>


<script setup name="BasicForm">
import dayjs from 'dayjs'
import LabelDes from '../LabelDes.vue'
import tool from '@/utils/tool'
import appInfoApi from '@/api/biz/appInfoApi'
import roleApi from '@/api/sys/roleApi'
import { cloneDeep } from 'lodash-es'
import { message } from 'ant-design-vue'
import sysConfig from '@/config/index'
import store from '@/store'
import { useRoute } from 'vue-router'
const route = useRoute()
const { isImport } = route.query
const emit = defineEmits(['getVariable'])
// const rules = [{ required: true, message: '请输入原因', trigger: 'blur' }]
const formRef = ref()
const appRangeLists = ref([])
const appRangeArr = ref([])
const personList = ref([])
const fwlist = ref([])
const pcTodoShow = ref(false)
const appTodoShow = ref(false)
const appContact = ref('')
// 表单数据
const formData = ref({
	mainSite: '',
	isPcTodo: '0',
	isPcReadtodo: '0',
	isAppTodo: '0',
	isAppReadtodo: '0',
	noAccessTypeRemark: undefined,
	// appAccess: '1',
	apps: '1'
	// appStatus: '1'
})
// 单选option
const radioOption = [
	{ label: '是', value: '1' },
	{ label: '否', value: '0' }
]
const validCode = async (rule, value) => {
	const reg = /^[A-Za-z0-9]+$/
	if (!value) {
		return Promise.reject('请输入需求单编号')
	}
	if (!reg.test(value)) {
		return Promise.reject('请输入正确的需求单编号(字母、数字)')
	}
	return Promise.resolve()
}
const validName = async (rule, value) => {
	const reg = /[\u4E00-\u9FA5\uFE30-\uFFA0]/
	if (!value) {
		return Promise.reject('请输入应用名称')
	}
	if (!reg.test(value)) {
		return Promise.reject('应用名称必须存在汉字')
	}
	return Promise.resolve()
}
const validDes = async (rule, value) => {
	if (!value) {
		return Promise.reject('请输入应用介绍')
	}
	if (value.includes("'")) {
		return Promise.reject('您输入存在无效字符" \' "，请重新填写')
	}
	return Promise.resolve()
}
const wsyy =
	'根据集团管理要求，为保证移动办公体验，需应用进行双端待办待阅同步接入，如无法双端同步，需填写原因并进行归口业务管理部门审核'
// 默认要校验的
const formRules = reactive({
	appName: [{ required: true, validator: validName, trigger: 'blur' }],
	appCategory: [{ required: true, message: '请输选择应用分类', trigger: 'blur' }],
	appRange: [{ required: true, message: '请选择应用范围', trigger: 'blur' }],
	// appCode: [{ required: true, message: '请输入应用ID', trigger: 'blur' }],
	// appKeywords: [{ required: true, message: '请输入应用关键字', trigger: 'blur' }],
	// appStatus: [{ required: true, message: '请选择应用状态', trigger: 'blur' }],
	appContact_s: [{ required: true, message: '请选择项目经理', trigger: 'blur' }],
	versionNumber: [{ required: true, message: '请输入技术支持', trigger: 'blur' }],
	operationsSupport: [{ required: true, message: '请输入反馈接收人', trigger: 'blur' }],
	threeSystemName: [{ required: true, message: '请输入应用三级系统名', tirgger: 'blur' }],
	// reqFormCode: [{ required: true, validator: validCode, trigger: 'blur' }],
	appAccountid: [{ required: true, message: '请输入用户范围', trigger: 'blur' }],
	validTime: [{ required: true, message: '请输入应用有效期', trigger: 'blur' }],
	appAccess: [{ required: true, message: '请选择双端接入', trigger: 'blur' }],
	appDescription: [{ required: true, validator: validDes, trigger: 'blur' }],
	noAccessTypeRemark: [{ required: true, message: '请选择原因', trigger: 'blur' }],
	platformBelongId: [{ required: true, message: '请选择应用归属', trigger: 'blur' }],
	appOnlineTime: [{ required: true, message: '请选择移动端预计上线时间', trigger: 'blur' }],
	appRemark: [{ required: true, message: '请输入原因', trigger: 'blur' }]
})
const formOption = [
	[
		{ label: '应用名称', type: 'text', prop: 'appName', placeholder: '请输入应用名称不超过20字', maxlength: 20 },
		{
			label: '应用分类',
			type: 'select',
			prop: 'appCategory',
			placeholder: '选择应用分类',
			option: tool.dictList('APP_CLASS'),
			description:
				'①党建和管理类应用是指应用归口业务管理部门为以下部门的应用: 综合部、企业发展部、资产运营部、财务部支人力资源部、技术部、资采购与管理部、审计部、法律部、党群工作部、纪检组/监察局、集团工会②市场类用是指应用归口业务管理部门为以下部门的应用: 市场部、集团客户事业部、国际业务部、产品创新部、客户服务部、电子商务部、实体渠道部、监管事务部③支撑类应用是指应用归口业务管理部门为以下部门的应用:网络建设部、运行维护部、信息化部。'
		},
		{
			label: '应用范围',
			type: 'select1',
			prop: 'appRange',
			placeholder: '选择应用范围',
			option: tool.dictList('app_range'),
			// option: fwlist.value,
			description: '1.总部应用2.全国应用--归属集中应用；3.省分应用4.子公司应用--归属省分应用；'
		}
	],
	[
		// { label: '应用ID', type: 'text', prop: 'appCode', placeholder: '请输入应用ID' },
		// { label: '应用关键字', type: 'text', prop: 'appKeywords', placeholder: '请输入应用关键字不超过15字', maxlength: 15 },
		// { label: '应用状态', type: 'radio', prop: 'appStatus', placeholder: '' }
		{
			label: '项目经理',
			type: 'appContact',
			prop: 'appContact_s',
			placeholder: '请选择项目经理',
			option: personList.value
		},
		{ label: '技术支持', type: 'text', prop: 'versionNumber', placeholder: '姓名-手机号-邮箱' },
		{
			label: '应用三级系统名',
			isrequire: true,
			type: 'text',
			prop: 'threeSystemName',
			placeholder: '请输入应用三级系统名',
			maxlength: 30
		},
	],
	[
		{ label: '反馈接收人', type: 'text', prop: 'operationsSupport', placeholder: '姓名-手机号-联通邮箱' },
		// { label: '需求单编号', type: 'text', prop: 'reqFormCode', placeholder: '请输入需求单编号' },
		// { label: '用户范围', type: 'text', prop: 'appAccountid', placeholder: '请输入用户范围', description: '该字段仅联通办公使用，如创建省分应用，用户范围依然为全国应用' },
		{ label: '应用有效期', type: 'date', prop: 'validTime', placeholder: '请输入应用有效期' },
		{
			label: '应用归属',
			type: 'appRange',
			prop: 'platformBelongId',
			placeholder: '请选择应用归属',
			option: appRangeLists.value
		}
	],
	// [
	// 	{
	// 		label: '应用归属',
	// 		type: 'appRange',
	// 		prop: 'platformBelongId',
	// 		placeholder: '请选择应用归属',
	// 		option: appRangeLists.value
	// 	}
	// 	// {
	// 	// 	label: '移动端预计上线时间',
	// 	// 	type: 'TimeDate',
	// 	// 	prop: 'appOnlineTime',
	// 	// 	placeholder: '请选择移动端预计上线时间',
	// 	// 	description: '移动端计划对接时间'
	// 	// }
	// ]
	// [{ label: '移动端预计上线时间', type: 'TimeDate', prop: 'appOnlineTime', placeholder: '请选择移动端预计上线时间' }]
]

onMounted(() => {
	appInfoApiList()
	getfwlist()
})
const arrListFilter = (v) => {
	if (v === '1') {
		//总部
		appRangeLists.value = appRangeArr.value.filter((item) => item.deptId == '001000')
	}
	if (v === '2') {
		//省分
		appRangeLists.value = appRangeArr.value.filter((item) => item.orgName.includes('分公司'))
	}
	if (v === '3') {
		//子公司
		appRangeLists.value = appRangeArr.value.filter(
			(item) => !item.orgName.includes('分公司') && item.deptId != '001000' && item.deptId != 'na'
		)
	}
	if (v === '4') {
		//全国
		appRangeLists.value = appRangeArr.value.filter((item) => item.deptId !== '001000')
	}
}
const filterOption = (input, option) => {
	return option.orgName.indexOf(input) >= 0;
}
/*变更编辑  开始*/
const editDate = inject('editDate')
// const tableName = inject('tableName')
const tableName = route.query.tableName
const mobileName = ref([])
const forData = () => {
	formData.value.appAccess = formData.value.appAccess.split(',')
	if (formData.value.appAccess.includes('1')) {
		// if (tableName !== 'MOBILE') {
		pcTodoShow.value = true
		// }

	}
	if (formData.value.appAccess.includes('2')) {
		appTodoShow.value = true
	}
	mobileName.value = formData.value.appAccess.map(v => {
		if (v != '1' && v != '2') {
			v = '2'
		}
		return v
	})
}
const isEdit = computed(() => {
	// true是修改  false修改
	let bool = false
	// if (isImport) {
	// 	bool = true
	// } else {
	// 	bool = editDate.value ? true : false
	// }
	bool = editDate.value ? true : false
	return bool
})
if (editDate.value && !isImport) {
	// formRules.noAccessTypeRemark = undefined
	formData.value = cloneDeep(editDate.value)
	forData()
}
/*变更编辑  结束*/


const handleAccessChange = (e) => {
	appTodoShow.value = e.length > 1
	if (e.length > 1) {
		formData.value.isAppReadtodo = '0'
		formData.value.isAppTodo = '0'
	}
}




// 是否可以编辑双端
const isDisabled = () => {
	return editDate.value.appAccess !== '1'
}



const props = defineProps({
	importOk: Boolean
})
// 导入成功
watch(() => props.importOk, (newData) => {
	if (newData) {
		let datas = store.state.appinfo.importData
		formData.value = cloneDeep(datas)
		arrListFilter(formData.value.appRange)
		appContactChange(formData.value.appContact)
		forData()
	}
})


// const mobileName = computed(() => {
// 	let arr = formData.value.appAccess.map(v => {
// 		if (v != '1' && v != '2') {
// 			v = '2'
// 		}
// 		return v
// 	})
// 	return arr
// })

// 应用联系人变化事件
const appContactChange = (oid) => {
	if (oid) {
		let obj = personList.value.find((v) => v.id == oid)
		if (obj) {
			formData.value.appContact_s = `${obj.name} ${obj.phone || ''} ${obj.email || ''}`
			formData.value.appContact = oid
		} else {
			formData.value.appContact_s = ''
			formData.value.appContact = ''
		}
	}
}

// 归属select变化 获取简称
const handleChange = (e) => {
	if (e === '001000') {
		formData.value.mainSite = 'np'
		formData.value.technicalSupport = '总部'
	} else {
		const extJson = appRangeArr.value.find((v) => v.deptId === e)
		formData.value.mainSite = extJson.mainSite
		formData.value.technicalSupport = extJson.orgName
	}
}

// 应用范围变更显示不同的流程图, 过滤应用归属选项
const appRange = ref()
const appRangeLi = ref([])
const handleRnChange = (v) => {
	appRange.value = v
	formData.value.platformBelongId = null

	arrListFilter(v)
	// appRangeLists.value
}

const range = (start, end) => {
	const result = []
	for (let i = start; i < end; i++) {
		result.push(i)
	}
	return result
}
const disabledDate = (current) => {
	// Can not select days before today and today
	return current && current < dayjs().endOf('day')
}
// const disabledDateTime = () => {
// 	return {
// 		disabledHours: () => range(0, 24).splice(4, 20),
// 		disabledMinutes: () => range(30, 60),
// 		disabledSeconds: () => [55, 56]
// 	}
// }
const pick = ref(null)
// 时间选择永久
const lasting = () => {
	const now = dayjs().add(50, 'year').format('YYYY-MM-DD')
	formData.value.validTime = now
	pick.value[0].blur()
}

// 选人
// const selectPerson = () => {
// 	console.log(123)
// }
// 双端变化事件 1-门户端 2-移动端
const todoRead = ['isPcTodo', 'isPcReadtodo', 'isAppTodo', 'isAppReadtodo']
watch(
	() => formData.value?.appAccess,
	(newValue, oldValue) => {
		if (newValue?.length > 0) {
			let bool = todoRead.some((v) => formData.value[v] == 0)
			// formRules.noAccessRemark = bool ? rules : ''
		}
	},
	{ immediate: true }
)
const isShowTime = computed(() => {
	let bool = false
	// 只选门户接入待办待阅并选择否
	if (formData.value.appAccess?.length == 1 && formData.value.appAccess[0] == 1) {
		if (formData.value.isPcReadtodo == '0' && formData.value.isPcTodo == '0') {
			bool = false
			formData.value.appOnlineTime = ''
		} else {
			bool = true
		}
	} else if (formData.value.appAccess?.length > 1) {
		// 双端接入都选择是需要填写移动端上线时间
		if (todoRead.some(v => formData.value[v] == '0')) {
			bool = false
			formData.value.appOnlineTime = ''
		} else {
			bool = true
		}
	} else if (!formData.value.appAccess || formData.value.appAccess?.length == 0) {
		bool = false
	} else {
		bool = true
	}
	return bool
})
// 不接入移动端原因
let showPhoneRemark = computed(() => {
	let bool = true
	if (formData.value.isAppTodo === formData.value.isPcTodo && formData.value.isPcReadtodo === formData.value.isAppReadtodo) {
		bool = false
	}
	return bool
})
// pc待办radio  1是  0否
const handleTodoChange = (e) => {
	const { value } = e.target
	// if (formData.value.appAccess && formData.value.appAccess.length > 0 && formData.value.appAccess.some((v) => v == 1)) {
	// 	if (tableName && tableName.includes('APP')) {
	// 		formData.value.isPcTodo = editDate.value.isPcTodo
	// 		message.warning('门户端待办待阅功能，需在门户端应用变更')
	// 		return false
	// 	}
	// }

	emit('getVariable', value, 'isPcTodo')
	// 如果选择’是‘，待阅也改成是
	// formData.value.isPcReadtodo = value === '0' ? '0' : '1'
	if (value === '0') {
		// formRules.noAccessTypeRemark = undefined
		formData.value.noAccessTypeRemark = undefined
		// if (formData.value.appAccess && formData.value.appAccess.length > 1) {
		// 	formData.value.isAppTodo = '0'
		// 	formData.value.isAppReadtodo = '0'
		// }
	} else {
		// 如果选择’是‘，判断移动端待办=否 ？验证 ：不验证
		// formRules.noAccessTypeRemark = formData.value.isAppTodo == '0' ? rules : undefined
		if (formData.value.isAppTodo == '1') {
			formData.value.noAccessTypeRemark = undefined
		}
	}
}
// 移动待办radio  1是  0否
const handleTodoChangePhone = (e) => {
	const { value } = e.target
	emit('getVariable', value, 'isAppTodo')
	if (value === '0') {
		// formData.value.isAppReadtodo = '0'
		// formRules.noAccessTypeRemark = formData.value.isPcTodo == '1' ? rules : undefined
		if (formData.value.isPcTodo == '0') {
			formData.value.noAccessTypeRemark = undefined
		}
	} else {
		// formRules.noAccessTypeRemark = undefined
		formData.value.noAccessTypeRemark = undefined
	}
}
// pc待阅radio  1是  0否
const handleToReadChange = (e) => {
	const { value } = e.target
	// if (formData.value.appAccess && formData.value.appAccess.length > 0 && formData.value.appAccess.some((v) => v == 1)) {
	// 	if (tableName && tableName.includes('APP')) {
	// 		formData.value.isPcReadtodo = editDate.value.isPcReadtodo
	// 		message.warning('门户端待办待阅功能，需在门户端应用变更')
	// 		return false
	// 	}
	// }
	emit('getVariable', value, 'isPcReadtodo')
	if (formData.value.isPcTodo === '1' && formData.value.isAppTodo === '1') {
		if (value === '0') {
			// formRules.noAccessTypeRemark = undefined
			formData.value.noAccessTypeRemark = undefined
		} else {
			// formRules.noAccessTypeRemark = formData.value.isAppReadtodo == '0' ? rules : undefined
			if (formData.value.isAppReadtodo == '1') {
				formData.value.noAccessTypeRemark = undefined
			}
		}
	}

	// if (value === '0') {
	// 	formRules.noAccessRemark = rules
	// } else {
	// 	formRules.noAccessRemark = formData.value.isPcTodo === '0' ? rules : ''
	// }
}
const handleToReadChangePhone = (e) => {
	const { value } = e.target
	emit('getVariable', value, 'isAppReadtodo')
	if (formData.value.isPcTodo === '1' && formData.value.isAppTodo === '1') {
		if (value === '0') {
			// formRules.noAccessTypeRemark = formData.value.isPcReadtodo == '1' ? rules : undefined
			if (formData.value.isPcReadtodo == '0') {
				formData.value.noAccessTypeRemark = undefined
			}
		} else {
			// formRules.noAccessTypeRemark = undefined
			formData.value.noAccessTypeRemark = undefined
		}
	}

	// if (value === '0') {
	// 	formRules.noAccessRemark = rules
	// } else {
	// 	formRules.noAccessRemark = formData.value.isAppTodo === '0' ? rules : ''
	// }
}
const filt = () => {
	let obj = cloneDeep(formData.value);
	if (!isShowTime.value) {
		obj.appOnlineTime = '';
	}
	if (showPhoneRemark.value && obj.noAccessTypeRemark != 5) {
		obj.appRemark = null;
	}
	if (!showPhoneRemark.value) {
		obj.noAccessTypeRemark = null;
		obj.appRemark = null;
	}
	return obj
}
// 表单验证
const handleValidate = () => {
	return new Promise((resolve, reject) => {
		formRef.value
			.validate()
			.then(() => {
				console.log('成功')
				resolve(filt())
			})
			.catch(() => {
				console.log('失败')
				resolve(false)
			})
	})
}

const getfwlist = async () => {
	fwlist.value = await appInfoApi.getAppRangeListdl()
}
const appInfoApiList = async () => {
	// appRangeArr.value = await appInfoApi.queryAppRange()
	let arr = await roleApi.getPermissionsdl()
	let hqArr = arr.filter((v) => v.deptId === '001000')
	let allArr = arr.filter((v) => v.deptId !== '001000')
	allArr.sort((a, b) => a.deptId - b.deptId)
	const unicoms = sysConfig.UNICOM_APPRANG
	appRangeArr.value = [...unicoms, ...hqArr, ...allArr]
	if (editDate.value && !isImport) {
		arrListFilter(formData.value.appRange)
	}
}

const isPM = () => {
	appInfoApi.isPM().then((data) => {
		personList.value = data
		// 如果是修改 获取显示的应用联系人
		if (editDate.value && !isImport) {
			appContactChange(formData.value.appContact)
		}
	})
}
isPM()

defineExpose({
	handleValidate,
	appRange
})
</script>

<style lang="less" scoped>
.tit {
	color: rgb(40, 40, 40);
	font-family: PingFang SC;
	font-size: 18px;
	font-weight: 600;
	line-height: 28px;
	letter-spacing: 0px;
	text-align: left;
}

.form-box {
	margin-top: 14px;
	padding-bottom: 30px;

	.labelCla {
		padding: 0 0 8px;

		.label-fon {
			margin-right: 10px;
		}
	}

	&-inp {
		border-radius: 4px;
		border: 1px solid rgb(206, 206, 206);
	}
}

.brfr::before {
	display: inline-block;
	margin-right: 4px;
	color: var(--highlight-color);
	font-size: 14px;
	font-family: SimSun, sans-serif;
	line-height: 1;
	content: '*';
}
</style>
